package cn.stazxr.deepseekchat;

import lombok.extern.slf4j.Slf4j;
import org.fusesource.jansi.Ansi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Main class for DeepSeekChatApplication
 *
 * @author talentestors
 * @version 1.1
 * @since 2025.3.14
 **/
@Slf4j
@SpringBootApplication
public class DeepSeekChatApplication {

	public static void main(String[] args) throws UnknownHostException {
		ApplicationContext application = SpringApplication.run(DeepSeekChatApplication.class, args);
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String path = env.getProperty("server.servlet.context-path");
		if (!StringUtils.hasLength(path)) {
			path = "";
		}
		log.info(new Ansi().fgGreen().a("""
			\n
			\t---------------------------------------------------------------
			\t\tApplication is running! Access URLs:
			\t\tLocal 访问网址: \t\thttp://localhost:{}{}
			\t\tExternal 访问网址: \thttp://{}:{}{}
			\t---------------------------------------------------------------
			""").reset().toString(), port, path, ip, port, path);
		String jvmName = ManagementFactory.getRuntimeMXBean().getName();
		log.info("当前项目进程号：{}", jvmName.split("@")[0]);
	}

}
